package src.io;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * 对象流
 */
public class OOSDemo {
        public static void main(String[] args) throws IOException {
                String name="璐璐";
                int age=15;
                String gender="女";
                String[] otherInfo={"是一位LOL英雄","是一个可爱的辅助"};
                Student ll=new Student(name,age,gender,otherInfo);
                System.out.println(ll);
                /*
                对象输出流在序列化对象时 需要保证序列化对象实现Serializable接口
                否则会报出NotSerializableException异常
                 */
                FileOutputStream fos=new FileOutputStream("student.obj");
                ObjectOutputStream oos=new ObjectOutputStream(fos);
                oos.writeObject(ll);
                System.out.println("写出完毕！");
                oos.close();
        }
}
